package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchAmountWater;
import com.ruoyi.system.service.IDispatchAmountWaterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水量分析报Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchAmountWater")
public class DispatchAmountWaterController extends BaseController
{
    @Autowired
    private IDispatchAmountWaterService dispatchAmountWaterService;

    /**
     * 查询水量分析报列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchAmountWater dispatchAmountWater)
    {
        startPage();
        List<DispatchAmountWater> list = dispatchAmountWaterService.selectDispatchAmountWaterList(dispatchAmountWater);
        return getDataTable(list);
    }

    /**
     * 导出水量分析报列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:export')")
    @Log(title = "水量分析报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchAmountWater dispatchAmountWater)
    {
        List<DispatchAmountWater> list = dispatchAmountWaterService.selectDispatchAmountWaterList(dispatchAmountWater);
        ExcelUtil<DispatchAmountWater> util = new ExcelUtil<DispatchAmountWater>(DispatchAmountWater.class);
        util.exportExcel(response, list, "水量分析报数据");
    }

    /**
     * 获取水量分析报详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:query')")
    @GetMapping(value = "/{amountWaterId}")
    public AjaxResult getInfo(@PathVariable("amountWaterId") Long amountWaterId)
    {
        return success(dispatchAmountWaterService.selectDispatchAmountWaterByAmountWaterId(amountWaterId));
    }

    /**
     * 新增水量分析报
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:add')")
    @Log(title = "水量分析报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchAmountWater dispatchAmountWater)
    {
        return toAjax(dispatchAmountWaterService.insertDispatchAmountWater(dispatchAmountWater));
    }

    /**
     * 修改水量分析报
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:edit')")
    @Log(title = "水量分析报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchAmountWater dispatchAmountWater)
    {
        return toAjax(dispatchAmountWaterService.updateDispatchAmountWater(dispatchAmountWater));
    }

    /**
     * 删除水量分析报
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAmountWater:remove')")
    @Log(title = "水量分析报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{amountWaterIds}")
    public AjaxResult remove(@PathVariable Long[] amountWaterIds)
    {
        return toAjax(dispatchAmountWaterService.deleteDispatchAmountWaterByAmountWaterIds(amountWaterIds));
    }
}
